home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
The World of Computer Software.iso
/
prbgi097.zip
/
PRINTBGI.DOC
< prev
next >
Wrap
Text File
|
1992-12-15
|
14KB
|
280 lines
#define C_only
#define Pascal_only
Documentation of PRINTBGI package v0.97 (C) Andrzej Resztak 1991,1992,
all rights reserved.
To contact the author write to
Andrzej Resztak
ul. K. Wallenroda 2c/18
20-607 Lublin
POLAND
or (preferably) to e-mail address:
Resztak@PLUMCS11.bitnet
Introduction
============
This is the version 0.97 of my PrintBGI toolkit. It was developed to
help programmers using Borland languages (Borland/Turbo C(++)
or Turbo Pascal) and BGI drivers to print graphics on the printer
(and in the future on the other devices) as easy as you can draw it
on the screen. In fact even more, the same function can produce
it's output on a screen or on a printer according to conditions
at which it was called.
It's really easy to learn. Developing your own applications does
not require writing two similar procedures (one for screen drawing
and the other for printer or plotter).
Maintenance of the code is simple, since all extensions or bug fixes
must be made in one place only. I hope you will enjoy this package.
For registration, license and payment see REGISTER.DOC.
#if kkkkk
For examples description see EXAMPLE.DOC.
#endif
This file contains all technical news you must understand to use
this package easy and effectively.
It is quite possibly that this program may not work on your
printer. For example I have never tested it on original IBM printer.
Of course it was tested on some compatible printers but I cannot be
quite sure which command is "compatible" and which is an enhancement.
So please, let me know if this program does not work with your printer.
My address is given at the end of this file.
SOME OVERVIEW
==============
This package can be divided into two independent parts. First is
BGI driver called by me BItImage BGI driver. This driver can be used
to create bit maps of any size of any picture. Note however that
the BGI driver does only some low level work (hardware specific) and
in most cases it depends on high level routines contained in Borland
graphics library kernel. Since there are some differences between printer
and screen oriented devices the initialization of my BitImage BGI
driver is somewhat different of initialization of standard Borland
video BGI drivers. For example it cannot perform any auto detection;
specifying printer being used does not determine the size of the graphic
output and there is some more minor differences. Because of these
differences you must call some PRT_Setxxxxxxx functions of the package to
specify parameters at which you want the BitImage driver to work. And
initialization of the driver should be done using PRT_initgraph function
instead of standard initgraph routine.
The second part of the package make routines contained in PRTGRAPH library
which hide some of the differences between my BitImage driver and
standard Borland video drivers. They also will make it very easy to print
something on your output device (currently only the dot matrix printers).
Now I describe you the easiest way you can add graphic output
to your programs using this PRINTBGI toolkit. Other sections
will let you know some more features, but this section is very good
for beginning, I hope.
#if C_only
For C users.
First, I highly recommend you to include prototypes of all functions
defined in PRINTBGI package by just inserting
#include <PRTGRAPH.H>
statement at the beginning of your module. Although it is not
necessary I also recommend you to place PRTGRAPH module after any standard
modules you use. It'll enable me some tricky modifications in the future
versions of this package.
You must also remember about linking in PRTGRAPH.LIB either
listing it in PRJ file in integrated environment or adding at the
command line invoking stand alone version of the compiler (or linker).
#endif C_only
#if Pascal_only
For Pascal users.
You must list PRTGRAPH unit (among other units you are using) in the
uses clause. You may also list PDrivers unit if you want to use symbolic
constants defined in it.
Although it is not necessary I recommend you to place PRTGRAPH
module after any standard modules you use. It'll enable me some tricky
modifications in the future versions of this package.
#endif Pascal_only
Next I assume that you like modular structure programming and have
routine called (say) DrawFunc which meets following conditions.
- It draws on the screen the picture you want to print it out.
- It does not use any nonstandard procedures (that is not
defined in GRAPH.TPU or GRAPHICS.LIB) to manipulate screen
output.
- It does not use initgraph,restorecrtmode,closegraph or setgraphmode
function. It simply assumes that appropriate graphic mode was
established before calling it and will be close down after
it finishes.
- It is written in BGI independent way. That is it uses getmaxx,
getmaxy, getmaxcolor, getaspectratio to get device dependent
characteristic and scales all output according to it.
- If you are using my recommended way to print your picture out, that
is you are using PRT_PrintBGI function then it may happen that this
function will call your drawing routine few or several times to print
out the whole picture. This may happen when there is not enough free
memory to build the whole bit image map of the picture at once. In
that case the bit map will be created piece by piece (each time
calling your drawing routine).
So, although it is not necessary it is recommended that your routine
will draw the same picture (pixel in pixel) each time it will be
called by PRT_PrintBGI function. Of course in the next invoke
of the PRT_PrintBGI routine your DrawFunc may draw something
completely different.
- It is declared as huge function if you are using C compiler.
( If it is not your case (you don't have such a function) you may
either rewrite your code to have such a function or use some lower
level functions included in this package. I once again highly
recommend you to choose the first method. )
If you have such a function you must inform the package what kind
of printer you have and at what resolution you want it to operate.
To do that just call PRT_SetPrinterDrv function with appropriate parameters
PrinterNo and ModeNo (use constants defined in PRTGRAPH.H or in
PRTGRAPH.PAS) and PRT_SetPicture to define size and other picture options.
For example the following statements may print out picture drawn by
DrawFunc on the IBM ProPrinter.
#if C_only
{ /* C version */
int PRTdrv,PRTmode,ReturnCode;
PRT_LinkDrivers(); /* link drivers definitions into an executable code
*/
PRT_SetPrinterDrv ( IBM9, IBM9_120x72 );
PRT_SetPicture ( 4000,3000, PRT_INVERSE );
PRTdrv = DETECT;
PRTmode=0;
/* If you want you may linked in the BitImage BGI driver into the */
/* EXE file. To do so remove comment markers from the following two lines. */
/* PRTdrv = PRT_installuserdriver ( "BitImage", NULL ); */
/* PRT_registerfarbgidriver ( BitImage ); */
ReturnCode = PRT_PrintBGI ( &PRTdrv,&PRTmode,"d:\\bc\\bgi",
DrawFunc, NULL );
}
#endif
#if Pascal_only
(* Pascal version *)
var PRTdrv,PRTmode,ReturnCode : integer;
Begin
rc:=PRT_LinkDrivers; { link drivers definitions into an executable code
}
PRT_SetPrinterDrv ( IBM9, IBM9_120x72 );
PRT_SetPicture ( 4000,3000, PRT_INVERSE );
{ rc := PRT_SetOutName('file.tst'); }
PRTdrv := DETECT;
PRTmode := 0;
(* If you want you may linked in the BitImage BGI driver into the *)
/* EXE file. To do so remove comment markers from the following two lines. */
{ PRTdrv := PRT_installuserdriver ( 'BitImage', NIL ); }
{ rc := PRT_registerbgidriver ( @BitImage ); }
rc := PRT_PrintBGI ( PRTdrv,PRTmode,'d:\tp\bgi', Draw, nil );
End;
#endif
In the best case it's all you have to do. Isn't it easy? I'm sure you
must admit it is.
Of course in most situations it is not enough. Above statements
will cause all output to be sent to the standard PRN device.
If you would like (or have to cause you don't have the printer at
LPT1 for example) to change these parameters you
should call some more functions of the PRINTBGI package as well
as you should code some lines to let user of your program specify
his own requirements. But all of this can be done!
You may also wish to print in inverse, reverse, with any density
at any size. The only disadvantage of using this package is that it
is perceptible slower than usual Print Screen procedures.
===============
SCREEN PREVIEW
===============
Starting with version 0.97 I've added screen preview option to my PrintBGI
package. It enables you to display at the screen buffer contents just
before printing. To do that you must register your own printing function
using PRT_SetUserPrintFunc function. An example of such routine is given
in both C and Pascal (see UserPRTF.C or UserUnit.pas file) and is used
in BGIDEMO example programs. These functions use some PrintBGI internal
functions to display buffer contents on the screen. I hope that they
are so simple than no more comments are needed.
In the way this feature is used in BGIDEMO examples it does not
give you full WYSIWYG. This is because different aspect ratio for the
screen and printer being used. So what will be printed on the printer
as the circle may be seen on the screen as an ellipse of different
radiuses. If you want full WYSIWYG you must build picture twice.
Once to let user see it and if he (or she) decides to print it out, build it
once again and print (this time without displaying it on the screen).
On the very fast computers this solution may be acceptable.
Note also that on black & white monitors you will not see color
pictures. To enable fast scrolling all high order bits are just ignored.
So you will see on the b&w screen odd colors only (as white) and all
even colors you will see as black.
In current release screen preview option will work only with the
following Borland's drivers EGA, EGA64, EGAMONO, HERC, VGA and CGA
in CGAHI(640x200 2 color) mode. It will not work with other Borland
supplied drivers and is likely to fail with most other vendors supplied
BGI drivers. It is your responsibility to ensure that you are using
one of compatible drivers, otherwise results are unpredictable.
Note that screen preview option may be not compatible with some future
printers drivers (e.g. Postscript driver is the first one candidate to not
allow screen preview option). This does not necessarily mean that some
drivers will not allow screen preview option to work, but that there is such
possibility that screen preview will not always be available. Thus
there is a function (called PRT_ScreenPreviewPossible) returning
nonzero (true) if screen preview option is available. Both examples
of user defined print function use it to ensure the proper work of buffer
display functions.
==============
MULTIPLE BGI's
==============
It seems that Borland designing BGI drivers thought only a little
about support of different graphic devices or few of them active
at the same time. In the documentation I have, BGI drivers have a field
(Device Type Identifier) value zero of which defines them as screen
driver, I believe. And in few places in the documentation there are
sentences about BGI drivers for printers or plotters. However I found
it impossible to have two or more BGI drivers active at the same time.
If it is quite possible that I am wrong it seems that you can use
initgraph function only if previously active BGI driver is closed
(using closegraph function). It makes it impossible to have screen in graphic
mode (screen BGI active) and print picture using printer BGI driver
at the same time. You cannot also use two graphic displays (IBM can
have two video adapters). Since Some users didn't like switching to text
mode during printing graphic I decided to do something to avoid this
problem. It was not easy and unfortunately I used some tricks which
may not work with future versions of BGI drivers (if there will be any).
Thus I developed small "pseudo" BGI driver and called it INTERBGI.
It is "pseudo" BGI driver because it does not perform any function
itself but calls real BGI driver to do real things. Using such interface
between Borland graphic kernel and BGI drivers enables me to switching
between them. In fact it's not so easy but we can stay with it.
Support for multiple BGI drivers allows you to initialize one BGI
driver without closing down the previously active one. The previously
active BGI driver stays in suspended mode and restores control
To see complete description of all functions available see
file FUNCTION.DOC.
/* end of PRINTBGI.DOC */